package com.epoint.rest;

import com.epoint.domain.SpcInspection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.configurationprocessor.json.JSONException;
import org.springframework.boot.configurationprocessor.json.JSONObject;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class MybatisRest {

    @Autowired
    private MybatisService mybatisService;

    @PostMapping("/getInspectionList_Mybatis")
    public Map<String, Object> getInspectionList_Mybatis(@RequestParam("params") JSONObject params) throws JSONException {

        List<SpcInspection> list = mybatisService.getInspectionList(params.getString("id"));

        Map<String, Object> result = new HashMap<>();
        Map<String, Object> custom = new HashMap<>();

        custom.put("inspectionlist", list);
        result.put("status", "200");
        result.put("custom", custom);
        return result;
    }
    @GetMapping("/getInspectionList_Docker")
    public Map<String, Object> getInspectionList_Docker() throws JSONException {
        List<SpcInspection > list = mybatisService.getInspectionAllList();
        Map<String, Object> result = new HashMap<>();
        Map<String, Object> custom = new HashMap<>();
        custom.put("inspectionlist", list);
        result.put("status", "200");
        result.put("custom", custom);
        return result;
    }

}
